from pyeasyaccept.commom.Configuration import Configuration
from pyeasyaccept.PythonEasyAcceptFacade import PythonEasyAcceptFacade
from pythoneasyaccept_test.TestFacade import TestFacade
import unittest
import os
"""
This class tests the PythonEasyAcceptFacade
@author: Artur Farias
"""
class PythonEasyAcceptFacadeTest2(unittest.TestCase):

    def setUp(self):
        self.FILE_SEPARATOR = Configuration.FILE_SEPARATOR  
        self.testFacade = TestFacade()
        self.configuration = Configuration()        
        self.root = self.configuration.getProjectRoot()
            
    def tearDown(self):
        pass
    
    """
    This test method tests the PythonEasyAccept API
    """
    def testAPI(self):
        
        scriptFile1 = self.root + self.configuration.TEST_SCRIPTS_LOCATION + self.FILE_SEPARATOR +"script01.txt"
        scriptFile2 = self.root + self.configuration.TEST_SCRIPTS_LOCATION + self.FILE_SEPARATOR + "script02.txt"
        
        files = [scriptFile1, scriptFile2]
        facade = PythonEasyAcceptFacade(self.testFacade, files);
        facade.executeTests()

# each script tests

        self.assertEquals("Test file: " + scriptFile1 + " | Passed Tests: " + str(facade.getScriptNumberOfPassedTests(scriptFile1)) + " | Not Passed Tests: " + str(facade.getScriptNumberOfNotPassedTests(scriptFile1)) + os.linesep + "Test file: " + scriptFile2 + " | Passed Tests: " + str(facade.getScriptNumberOfPassedTests(scriptFile2)) + " | Not Passed Tests: " + str(facade.getScriptNumberOfNotPassedTests(scriptFile2)) + os.linesep, facade.getSummarizedResults())
        
        self.assertEquals(facade.getScriptCompleteResults(scriptFile1)+ Configuration.WHITE_LINE_CODE + "======================== " + Configuration.WHITE_LINE_CODE + facade.getScriptCompleteResults(scriptFile2)+ Configuration.WHITE_LINE_CODE + "======================== " + Configuration.WHITE_LINE_CODE, facade.getCompleteResults())
        
        self.assertEquals(facade.getScriptSummarizedResults(scriptFile1) + os.linesep + os.linesep + "FAILURES:" + os.linesep + "At line 2: Was expected: 2, but got: 3" + os.linesep + "At line 3: Was expected: 3, but got: 4" + os.linesep, facade.getScriptCompleteResults(scriptFile1))
        
        self.assertEquals("Test file: " + scriptFile1 + " | Passed Tests: " + str(facade.getScriptNumberOfPassedTests(scriptFile1)) + " | Not Passed Tests: " + str(facade.getScriptNumberOfNotPassedTests(scriptFile1)), facade.getScriptSummarizedResults(scriptFile1))
        
if __name__ == '__main__':
    unittest.main()